﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TOUR.SZHOME.Attributes;
using TOUR.SZHOME.BLL;
using TOUR.SZHOME.Entity;

namespace tour.szhome.manage.area.Controllers
{
    [SelfOnly]
    public class ProjectImgController : Controller
    {
        //
        // GET: /ProjectImg/
        Projects_ImageBLL _pimgbll = new Projects_ImageBLL();

        public ActionResult Index(int id = 0, string pname = "")
        {
            ViewBag.ID = id;
            ViewBag.Name = pname;
            //ViewBag.List = _limgbll.GetListByJQID(id);
            ViewBag.uploadAddress = System.Configuration.ConfigurationManager.AppSettings["UploadAddress"];//获取上传文件地址 
            ViewBag.Folder = "big/";   //获取当前子文件夹

            //拿到各种type的相册列表
            var list = _pimgbll.GetListByXMID(id);
            ViewBag.sList = list.Where(x => x.TPLX == 0); //实景图
            ViewBag.xList = list.Where(x => x.TPLX == 1); //效果图
            ViewBag.gList = list.Where(x => x.TPLX == 2); //规划图
            ViewBag.pList = list.Where(x => x.TPLX == 3); //配套图
            ViewBag.hList = list.Where(x => x.TPLX == 4); //活动图
            return View();
        }

        /// <summary>
        /// 新增编辑
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [ActionName("json_edit")]
        public ActionResult Json_Edit(Projects_ImageEntity model)
        {
            return Json(_pimgbll.Edit(model), JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="xid">相册ID</param>
        /// <returns></returns>
        [ActionName("json_delete")]
        public ActionResult Json_Del(int xid)
        {
            return Json(_pimgbll.DelByID(xid), JsonRequestBehavior.AllowGet);
        }

    }
}
